package com.person.jiaiplan.service.impl;

import com.person.jiaiplan.contant.ConstGroupEnum;
import com.person.jiaiplan.pojo.dto.SelectConfigResDTO;
import com.person.jiaiplan.pojo.dto.SelectConfigResDetail;
import com.person.jiaiplan.service.BasicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class BasicServiceImpl implements BasicService {

    @Override
    public List<SelectConfigResDTO> getSelectConfig() {
        Map<String, Map<String, Object>> resultMap = ConstGroupEnum.map;

        List<SelectConfigResDTO> selectConfigResDTOList = new LinkedList<>();

        for (Map.Entry<String, Map<String, Object>> entry : resultMap.entrySet()) {
            SelectConfigResDTO selectConfigResDTO = new SelectConfigResDTO();
            selectConfigResDTO.setGroup(entry.getKey());
            List<SelectConfigResDetail> dtoList = new LinkedList<>();
            Map<String, Object> valueMap = entry.getValue();
            for (Map.Entry<String, Object> vo : valueMap.entrySet()) {
                SelectConfigResDetail resDTO = new SelectConfigResDetail();
                resDTO.setLabel(vo.getKey());
                resDTO.setValue(vo.getValue());
                dtoList.add(resDTO);
            }
            selectConfigResDTO.setGroupDetail(dtoList);
            selectConfigResDTOList.add(selectConfigResDTO);
        }

        return selectConfigResDTOList;
    }
}
